home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
tlx_sq15.zip
/
MEGAMAIL.SLT
< prev
next >
Wrap
Text File
|
1990-11-02
|
10KB
|
310 lines
//-----------------------------------------------------------
// MEGAMAIL.SL? Telix script to fetch mail from a PCBoard BBS.
//
// This script is normally called from the script PCB.SLC.
//
// Please look at the comments through the whole file, and modify to
// suit your needs, BEFORE you use it. Then recompile with CS MEGAMAIL.
//-----------------------------------------------------------
//
// Author: Inge Vabekk
// Hamangskogen 108
// N-1300 SANDVIKA
// NORWAY
str myprot [2] // My protocol
,codename [10] // BBS codename.
,help [80] // Help line.
,runstr [80] // DSZ runstring (if used).
// Script and global names:
,global []="GLOBAL" // Global script.
,Cprot []="CPROT" // Current protocol.
,prompt []="PROMPT" // Current command prompt.
,mdir []="MDIR" // Mail directory.
,dsz []="DSZ" // Code for DSZ (if in use).
;
int tol = 300 // No activity for 30 sec.
,tmark // makes script time out.
,stat
,PCBver // PCB version
;
//-----------------------------------------------------------
// MEGAmail script is entered here.
//-----------------------------------------------------------
main()
{
int c, i, // For tracking:
un, // Upload Now
dn, // Download Now
rt, // Return.
pd, // Back to ProDoor.
W; // Still working...
entry(); // Updates status bar.
read (cprot,myprot) ; // Get current BBS protocol.
un = track ("Upload Your",0); // Wait for message.
pd = track ("Prodoor",1); // Prodoor again.
W = track ("se wait ...",0); // Returning.
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == un)
break; // Upload Now?
goto done; // Door aborted.
}
if (!carrier()) goto done; // Fail?
i = 0;
do
{ c = cgetct(2); // Wait for a character.
printc(c);
if (isupper(c)) // If "A" - "Z"
{ setchr(codename,i,c); // put it into name.
++i;
}
} while (c != '.');
setchr (codename,i,0); // Terminate with a zero.
// See if we can find the upload file.
// ----------------------------------------------------------
help = _up_dir; // Get upload directory.
strcat (help,codename); // Copy codename to filename.
strcat (help,".UL"); // Add extension.
if (filesize(help) <= 0) // No file to send?
{ megabort();
goto done;
}
// Define new strings for tracking.
//-----------------------------------------------------------
un = track (" Now...",0); // Upload Now.
dn = track ("gin Your",0); // Download now.
rt = track ("system..",0); // Return to system.
W = track ("rking On",0); // Still working....
tmark = timer_start (tol); // Give me a minute.
while ((stat=trig()) > 0) // answer any questions.
{ if (stat == un) // Upload Now?
{ track_free (un); // Release this track.
send_file(); // Send it.
}
else if (stat == rt) // Return to system?
goto abort;
else if (stat == dn) // Download now?
break;
else if (stat == W) // Still working?
; // Just wait....
}
release(); // Free all tracks and timer.
get_file();
if (carrier()) goto done;
abort:
release();
failtone();
return (-1);
done:
goodtone();
return (0);
}
//-----------------------------------------------------------
// Send upload mail file.
//-----------------------------------------------------------
send_file()
{
int c;
if (read (dsz,runstr) > 0) // DSZ?
{ strcat (runstr,help); // Add filename to runstring.
while ((c=strchr(runstr,0,'\')) > 0)
setchr (runstr,c,'/'); // Replace '\' by '/'.
run (dsz,runstr,0); // Use DSZ.
flushbuf(); // Flush input buffer.
}
else
send (subchr(myprot,0),help); // Send file.
}
//-----------------------------------------------------------
// Get download mail file.
//-----------------------------------------------------------
get_file()
{
int save;
save = _zmod_auto; // Save auto zmodem indicator.
_zmod_auto = 0;
delay (5);
if (read (dsz,runstr) < 0) // DSZ not defined:
{ help = _down_dir; // Save download dir.
read (mdir,_down_dir); // and change it.
receive (subchr(myprot,0),"");
_down_dir = help; // Restore download dir.
}
else
{ newdir (_down_dir); // DSZ: Change directory.
strcat (runstr," r"); // Add parameters: Receive.
strlower (myprot); // Protocol.
strcat (runstr,myprot);
strcat (runstr," -y"); // OK to overwrite.
run (dsz,runstr,0); // Use DSZ.
newdir (_telix_dir); // Go back to TELIX directory!
}
flushbuf(); // Flush input buffer.
if (myprot=="Z")
waitfor ("**00",1); // Wait until this has passed, then
_zmod_auto = save; // restore auto zmodem indicator.
_down_dir = help; // Restore download dir.
read (prompt,help); // Get command prompt.
waitfor (help,20); // Wait for next command.
}
//----------------------------------------------------------
// Abort Megamail door.
//-----------------------------------------------------------
megabort()
{
int i, t1;
for (i=0; i<3; ++i) // Three short beeps.
{ tone (2400,6);
delay(1);
}
mess ("No upload mail - Attempting to abort MegaMail door");
t1 = track (" Command",0); // Command
track (" wait ..",0); // Please wait...
track ("Prodoor",1); // Prodoor again.
i=0;
tmark = timer_start (tol); // Give me thirty seconds.
do
{ cputs ("^X"); // Send Control-X.
delay (2); // as long as we're online.
if ((stat=track_hit(0))) // If trigger,
timer_restart (tmark,tol); // reset timer.
if (stat==t1) // If command, count to
{ if (++i > 2) break; // three to remove CNTL-X-es
cputs ("^M"); // from his input buffer.
}
} while (!time_up(tmark) && carrier());
return; // Return.
}
//-----------------------------------------------------------
// Routine to update colors and status bar.
//-----------------------------------------------------------
entry ()
{
_back_color = 1;
_fore_color = 14;
update_term();
}
//-----------------------------------------------------------
// Play fail tone.
//-----------------------------------------------------------
failtone()
{
int n;
for (n=140; n > 10; n = 100*n/120)
{ tone